shop.product = {
	viewOrderedCustomerList: function(itemId) {
		shop.show_overlay_popup('list-ordered-customer', 'Danh sách người mua',
		shop.product.theme.viewOrderedCustomerList(itemId, 'list-ordered-customer', 'Danh sách người mua'),
		{
			background: {
				'background-color' : 'transparent'
			},
			border: {
				'background-color' : 'transparent',
				'padding' : '0px'
			},
			title: {
				'display' : 'none'
			},
			content: {
				'padding' : '0px',
				'width' : '400px'
			},
			release:function(){
				
			},
			onclose:function(){
				
			}
		});
	},
	theme: {
		viewOrderedCustomerList:function(itemId, id, title, close, opt, txt){
			var html = '';
			var data = '';
			var t = 0, inc, cs, i;
			shop.show_loading();
			$.ajax({
				async: false,
				url: 'ajax.php?act=item&code=listBuyer',
				type: 'GET',
				data: {id: itemId, limit: 500},
				dataType: 'json',
				success: function(obj) {
					if (obj.err == 0) {
						t = parseInt(obj.total);
						inc = t;
						cs = obj.customer;
						for (i in cs) {
							data += '<tr><td>'+(inc--)+'.</td><td>' + cs[i].name + '</td></tr>';
						}
					} else {
						html = '<div style="padding:5px">Có lỗi xảy ra! Vui lòng thử lại sau!</div>'
					}
				}
			});
			shop.hide_loading();
			if (t > 0) {
				html = shop.join
				('<div style="height:320px;overflow:scroll"><table width="100%" border="0" cellpadding="5" cellspacing="0">')
					('<tr style="background-color:silver"><td>STT</td><td>Tên</td></tr>')
					(data)
				('</table></div>')();
			}
			if(txt){
				return html;
			}
			return shop.popupSite(id, title, html, close, opt);
		}
	},
	conf:{
		product: {},
		itemJson: {},
		fb:[],
		itemHot: 2,
		now: TIME_NOW,
		popNow: TIME_NOW,
		show_sec: false
	},
	init:function(id, start, end, buyer, buyer_need, out_time, width, unit, timeType, is_end){
		width = width ? width : 140;
		shop.product.conf.product[id] = {
			id:	id,
			start: start,
			end: end,
			now: shop.product.conf.now,
			popNow: shop.product.conf.now,
			count: end - shop.product.conf.now,
			popCount: end - shop.product.conf.popNow,
			buyer: buyer,
			out_time: out_time,
			buyer_active: buyer_need,
			buyer_need: buyer_need,
			pick_time: '',
			step: width/100,
			max_width:width,
			percent: 'buyerPercent'+id, //buyerPercent
			time: 'timeCount'+id, 		//timeCount
			timeTitle: 'timeTitle'+id,	//timeTitle
			displayTime: timeType,
			counter_id : 0,
			updateTime: 5*60*1000,
//			updateTime: 1500,
			first:false,
			unit: unit,
			is_end: is_end == 1
		};

		//draw bar
		shop.product.drawBuyer(id);
		//start clock count time
		shop.product.countTime(id);
		//start updating
		if((shop.product.conf.product[id].buyer < shop.product.conf.product[id].buyer_need) &&
		   (shop.product.conf.product[id].end > shop.product.conf.now) &&
		   !shop.product.conf.product[id].is_end)
		{
			shop.product.update(id);
		}
	},
	popCountTime:function(id){
		shop.product.conf.product[id].popNow++;
		shop.product.conf.product[id].popCount--;
		if(shop.product.popDisplayTime(id)){
			shop.product.conf.product[id].counter_id = setTimeout(function(){shop.product.popCountTime(id)},1000);
		}else{
			var title = '',timeStr='';
			if(shop.product.conf.product[id].buyer >= shop.product.conf.product[id].buyer_need){//so luong nguoi mua da du
				title = 'Thời gian hết hàng';
				timeStr = shop.product.conf.product[id].out_time;
			}else{
				var title = 'Hết hạn lúc', time = 0;
				if(shop.product.conf.product[id].start > shop.product.conf.product[id].popNow){
					title = 'Thời gian bắt đầu';
					time  = shop.product.conf.product[id].start;
				}else if(shop.product.conf.product[id].end <= shop.product.conf.product[id].popNow || shop.product.conf.product[id].is_end){
					time  = shop.product.conf.product[id].end;
				}
				var d = new Date(time*1000),
				hour= d.getHours(),
				min = d.getMinutes(),
				day = d.getDate(),
				month = d.getMonth()+1;
				timeStr = (hour>9?'':'0')+(hour>0?hour:0)+'h'+(min>9?'':'0')+(min>0?min:0)+' ngày '+(day>9?'':'0')+(day>0?day:0)+'/'+(month>9?'':'0')+(month>0?month:0)+'/'+d.getFullYear();
			}
			//update time title
			jQuery('#pop'+shop.product.conf.product[id].timeTitle).html(title).addClass('v6TimeOverDie');
			jQuery('#pop'+shop.product.conf.product[id].time).html('<span class="timeOver">'+timeStr+'</span>');
		}
	},
	popDisplayTime:function(id){
		var day = Math.floor(shop.product.conf.product[id].popCount/86400),
		count= shop.product.conf.product[id].popCount%86400,
		hour = Math.floor(count/(60*60)),
		min = Math.floor((count%(60*60))/60),
		sec = Math.floor(count - hour*60*60 - min*60),
		color = '',
		colorDeal = '#54682D',
		numberProduct = shop.product.conf.product[id].buyer_need-shop.product.conf.product[id].buyer;

		//set lai mau cho deal
		if(shop.product.conf.product[id].start < shop.product.conf.product[id].popNow && day <= 0 && hour <= 0 && min <= 10){
			color = 'color:red';
			colorDeal = 'red';
		}else if(numberProduct <= 10 && numberProduct > 0){
			colorDeal = 'red';
		}
		jQuery('#deal'+id).css('color',colorDeal);

		if(shop.product.conf.product[id].displayTime){
			jQuery('#'+shop.product.conf.product[id].time+' .hours').html('<span style="'+color+'">'+(hour>9?'':'0')+(hour>0?hour:0)+'</span>');
			jQuery('#'+shop.product.conf.product[id].time+' .min').html('<span style="'+color+'">'+(min>9?'':'0')+(min>0?min:0)+'</span>');
			jQuery('#'+shop.product.conf.product[id].time+' .sec').html('<span style="'+color+'">'+((sec>9&&sec<60)?'':'0')+((sec>0&&sec<60)?sec:0)+'</span>');
		}else{
			var obj = shop.get_ele('pop'+shop.product.conf.product[id].time);
			if(obj){
				obj.innerHTML = '<span style="'+color+'">'+(day>0?(day+' ngày, '):'')+(hour>9?'':'0')+(hour>0?hour:0)+'<span style="text-transform:lowercase"> giờ </span> '+(min>9?'':'0')+(min>0?min:0)+' phút '+( (day<=0 || shop.product.conf.show_sec) ? (((sec>9&&sec<60)?'':'0')+((sec>0&&sec<60)?sec:0)+' giây'):"" )+'</span>';
				obj.innerHTML = '<span style="'+color+'">'+(day>0?(day+' ngày, '):'')+(hour>9?'':'0')+(hour>0?hour:0)+':'+(min>9?'':'0')+(min>0?min:0)+':'+(sec>9?'':'0')+(sec>0?sec:'0')+'</span>';
				obj.innerHTML = '<span style="'+color+'">'+(day>0?(day+' ngày '):'')+(hour>9?'':'0')+(hour>0?hour:0)+':'+(min>9?'':'0')+(min>0?min:0)+'&#146;:'+(sec>0?sec:'0')+'&#148;</span>';
//				obj.innerHTML ='<table  style="font-size:8px;font-style:normal;text-transform:uppercase;" align="center"><tbody><tr style="font-size:31px;color:#4c4c4c;">'+(day>0?'<td align="center">'+(day>0?(day>9?'':'0')+day:'')+'</td><td align="center" width="5" style="font-size:18px;vertical-align: middle;">:</td>':'')+(hour>0||day>0?'<td align="center">'+(hour>9?'':'0')+(hour>0?hour:0)+'</td><td align="center" width="5" style="font-size:18px;vertical-align: middle;">:</td>':'')+(min>0?'<td align="center" >'+(min>9?'':'0')+(min>0?min:0)+'</td><td align="center" width="5" style="font-size:18px;vertical-align: middle;">:</td>':'')+'<td  align="center">'+(sec>9?'':'0')+(sec>0?sec:'0')+'</td></tr><tr style="font-size:8px;color:#a8a8a8;">'+(day>0?'<td align="center">Ngày</td><td align="center"></td>':'')+(hour>0||day>0?'<td align="center">Giờ</td><td align="center"></td>':'')+(min>0?'<td align="center">Phút</td><td align="center"></td>':'')+'<td align="center">Giây</td></tr></tbody></table>';
			}else{
				return false;
			}
		}
		return hour>=0 && min >=0 && sec >= 0 && sec <= 59;
	},
	countTime:function(id){
		shop.product.conf.product[id].now++;
		shop.product.conf.product[id].count--;
		if(shop.product.displayTime(id)){
			shop.product.conf.product[id].counter_id = setTimeout(function(){shop.product.countTime(id)},1000);
		}else{
			var title = '',timeStr='';
			
			if(shop.product.conf.product[id].buyer >= shop.product.conf.product[id].buyer_need){//so luong nguoi mua da du
				title = 'Thời gian hết hàng';
				timeStr = shop.product.conf.product[id].out_time;
			}else{
				var title = 'Hết hạn lúc', time = 0;
				if(shop.product.conf.product[id].start > shop.product.conf.product[id].now){
					title = 'Thời gian bắt đầu';
					time  = shop.product.conf.product[id].start;
				}else if(shop.product.conf.product[id].end <= shop.product.conf.product[id].now || shop.product.conf.product[id].is_end){
					time  = shop.product.conf.product[id].end;
				}
				var d = new Date(time*1000),
				hour= d.getHours(),
				min = d.getMinutes(),
				day = d.getDate(),
				month = d.getMonth()+1;
				timeStr = (hour>9?'':'0')+(hour>0?hour:0)+'h'+(min>9?'':'0')+(min>0?min:0)+' ngày '+(day>9?'':'0')+(day>0?day:0)+'/'+(month>9?'':'0')+(month>0?month:0)+'/'+d.getFullYear();
			}
			//update time title
			jQuery('#'+shop.product.conf.product[id].timeTitle).html(title).addClass('v6TimeOverDie');
			jQuery('#'+shop.product.conf.product[id].time).html('<span class="timeOver">'+timeStr+'</span>');
		}
	},
	displayTime:function(id){
		var day = Math.floor(shop.product.conf.product[id].count/86400),
		count= shop.product.conf.product[id].count%86400,
		hour = Math.floor(count/(60*60)),
		min = Math.floor((count%(60*60))/60),
		sec = Math.floor(count - hour*60*60 - min*60),
		color = '',
		colorDeal = '#54682D',
		numberProduct = shop.product.conf.product[id].buyer_need-shop.product.conf.product[id].buyer;

		//set lai mau cho deal
		if(shop.product.conf.product[id].start < shop.product.conf.product[id].now && day <= 0 && hour <= 0 && min <= 10){
			color = 'color:red';
			colorDeal = 'red';
		}else if(numberProduct <= 10 && numberProduct > 0){
			colorDeal = 'red';
		}
		jQuery('#deal'+id).css('color',colorDeal);

		//neu het gio tra ve false
		if((shop.product.conf.product[id].buyer >= shop.product.conf.product[id].buyer_need) || (shop.product.conf.product[id].start > shop.product.conf.product[id].now) || (shop.product.conf.product[id].end < shop.product.conf.product[id].now) || shop.product.conf.product[id].is_end){
			var html = '',parent = jQuery('#productItem'+id);
			if(shop.product.conf.product[id].start < shop.product.conf.product[id].now){
				if(shop.product.conf.product[id].buyer >= shop.product.conf.product[id].buyer_need){
					html = '<div class="overTime mTop5">Đã hết cơ hội mua rẻ</div>';
				}else{
					html = '<div class="overTime mTop5">Đã hết cơ hội mua rẻ</div>';
				}
				html += '<center class="numBuyerOver">(Có <b>'+shop.product.conf.product[id].buyer+'</b> người đã mua được)</center>'
				jQuery('#event_end'+id).html(html);
				jQuery('.buying', parent).hide();
				jQuery('.stillRun', parent).hide();
				shop.product.conf.product[id].is_end = 1;
				jQuery('.buyNow', parent).addClass('buyNowOut');
			}else{
				jQuery('.buyNow', parent).addClass('buyNowWait');
			}
			return false;
		}

		if(shop.product.conf.product[id].displayTime){
			jQuery('#'+shop.product.conf.product[id].time+' .hours').html('<span style="'+color+'">'+(hour>9?'':'0')+(hour>0?hour:0)+'</span>');
			jQuery('#'+shop.product.conf.product[id].time+' .min').html('<span style="'+color+'">'+(min>9?'':'0')+(min>0?min:0)+'</span>');
			jQuery('#'+shop.product.conf.product[id].time+' .sec').html('<span style="'+color+'">'+((sec>9&&sec<60)?'':'0')+((sec>0&&sec<60)?sec:0)+'</span>');
		}else{
			var obj = shop.get_ele(shop.product.conf.product[id].time);
			if(obj){
				obj.innerHTML = '<span style="'+color+'">'+(day>0?(day+' ngày, '):'')+(hour>9?'':'0')+(hour>0?hour:0)+'<span style="text-transform:lowercase"> giờ </span> '+(min>9?'':'0')+(min>0?min:0)+' phút '+( (day<=0 || shop.product.conf.show_sec) ? (((sec>9&&sec<60)?'':'0')+((sec>0&&sec<60)?sec:0)+' giây'):"" )+'</span>';
				obj.innerHTML = '<span style="'+color+'">'+(day>0?(day+' ngày, '):'')+(hour>9?'':'0')+(hour>0?hour:0)+':'+(min>9?'':'0')+(min>0?min:0)+':'+(sec>9?'':'0')+(sec>0?sec:'0')+'</span>';
				obj.innerHTML = '<span style="'+color+'">'+(day>0?(day+' ngày '):'')+(hour>9?'':'0')+(hour>0?hour:0)+':'+(min>9?'':'0')+(min>0?min:0)+'&#146;:'+(sec>0?sec:'0')+'&#148;</span>';
//				obj.innerHTML ='<table  style="font-size:8px;font-style:normal;text-transform:uppercase;" align="center"><tbody><tr style="font-size:31px;color:#4c4c4c;">'+(day>0?'<td align="center">'+(day>0?(day>9?'':'0')+day:'')+'</td><td align="center" width="5" style="font-size:18px;vertical-align: middle;">:</td>':'')+(hour>0||day>0?'<td align="center">'+(hour>9?'':'0')+(hour>0?hour:0)+'</td><td align="center" width="5" style="font-size:18px;vertical-align: middle;">:</td>':'')+(min>0?'<td align="center" >'+(min>9?'':'0')+(min>0?min:0)+'</td><td align="center" width="5" style="font-size:18px;vertical-align: middle;">:</td>':'')+'<td  align="center">'+(sec>9?'':'0')+(sec>0?sec:'0')+'</td></tr><tr style="font-size:8px;color:#a8a8a8;">'+(day>0?'<td align="center">Ngày</td><td align="center"></td>':'')+(hour>0||day>0?'<td align="center">Giờ</td><td align="center"></td>':'')+(min>0?'<td align="center">Phút</td><td align="center"></td>':'')+'<td align="center">Giây</td></tr></tbody></table>';
			}else{
				return false;
			}
		}
		return hour>=0 && min >=0 && sec >= 0 && sec <= 59;
	},
	drawBuyer:function(id){
		var percent = (shop.product.conf.product[id].buyer_need == 0) ? 100 : Math.round(shop.product.conf.product[id].buyer / shop.product.conf.product[id].buyer_need * 100),
		width = Math.round(percent*shop.product.conf.product[id].step),
		divPer= shop.get_ele(shop.product.conf.product[id].percent);
		if(divPer){
			if(width > 0 && !jQuery(divPer).hasClass('buyerPercentOverZero')){
				divPer.className +=  ' buyerPercentOverZero';
			}
			if(width <= 4){
				if(!jQuery(divPer).hasClass('buyerPercentZero')){
					divPer.className += ' buyerPercentZero';
				}
				width = 4;
			}else{
				jQuery(divPer).removeClass('buyerPercentZero');
			}
			if(shop.product.conf.product[id].max_width - width <= 0){
				if(!jQuery(divPer).hasClass('buyerPercentFull')){
					divPer.className += ' buyerPercentFull';
				}
			}
			divPer.style.width = width+"px";
		}
	},
	update:function(id){
		if(!shop.product.conf.product[id].is_end){
			if(shop.product.conf.product[id].first){
				shop.ajax_popup("act=item&code=get-hot",'GET',{id:id},
				function(j){
					if(j.err == 0){
						if(j.data.id == id){
							shop.product.conf.product[id].now   =   parseInt(j.now);
							shop.product.conf.product[id].id 	=	parseInt(j.data.id);
							shop.product.conf.product[id].start =	parseInt(j.data.startTime);
							shop.product.conf.product[id].end	=	parseInt(j.data.endTime);
							shop.product.conf.product[id].count =	shop.product.conf.product[id].end - shop.product.conf.product[id].now;
							shop.product.conf.product[id].buyer =	parseInt(j.data.buyer);
							shop.product.conf.product[id].out_time = j.data.event_end;
							shop.product.conf.product[id].buyer_need = parseInt(j.data.buyer_need);
							shop.product.conf.product[id].buyer_active = parseInt(j.data.buyer_active);
							shop.product.conf.product[id].pick_time = j.data.pick_time;
							shop.product.conf.product[id].is_end = j.data.is_end == 1;
	
							var html = '', parent = jQuery('#productItem'+id);
							//update danh sach khach hang
							if(j.data.customer.length <= 0){
								html = shop.join
								('<center class="p10">')
									('<a href="javascript:void(0)" onclick="shop.cart.addItem('+j.data.id+','+j.data.startTime+','+j.data.endTime+','+j.data.buyer+','+j.data.buyer+')" title="Mua ngay">')
										('<img src="style/images/icon/icon_hand.png" alt="number one" />')
									('</a>')
									('<div class="mTop10">Hãy là <b>người đầu tiên</b> mua sản phẩm này</div>')
								('</center>')();
							}else{
								html = '<ul class="firstList">';
								var count = 1,
								total = parseInt(shop.product.conf.product[id].buyer),
								idx = 0;
								if(shop.product.conf.product[id].id == 73){
									total = 0;
									for(var t in j.data.customer){
										total++;
									}
								}
								for(var i in j.data.customer){
									idx = total - count + 1;
	
									html += shop.join
									('<li id="customer'+id+'_'+count+'"'+(count>=6?' class="hidden"':'')+'>')
									  ('<span class="f11" style="color:#999">'+shop.product.zero(idx, total)+'. </span>')
									  ('<span><a name="customer'+id+'_'+count+'">'+j.data.customer[i].name+'</a></span>')
									('</li>')();
									count++;
								}
								html +=	'</ul>';
								if(shop.product.conf.product[id].buyer >= 6){
									html += shop.join
									('<div class="more" align="right">')
										('<a href="javascript:void(0)" onclick="shop.closeMoreBuyer(this)" class="top fl" style="display:none" title="Thu lại"></a>')
										('<a href="javascript:void(0)" onclick="shop.showMoreBuyer(this)" title="Xem tiếp 20 người" class="f12" style="font-weight:normal;color:#0076b2">Xem thêm ></a>')
										('<div class="c"></div>')
									('</div>')();
								}
							}
							jQuery('div.listBuyer>div.mainBlueBoxNew', parent).html(html);
	
							//update so nguoi mua
							if(shop.product.conf.product[id].buyer > 0){
								jQuery('.buyerStatus', parent).html('<div class="numBuyer">(Đã có <b>'+shop.product.conf.product[id].buyer+'</b> người mua)</div>');
							}else{
								jQuery('.buyerStatus', parent).html('');
							}
							//update sản phẩm còn
							var con = shop.product.conf.product[id].buyer_need-shop.product.conf.product[id].buyer;
							if(con > 0){
								jQuery('#deal'+id).html('<span>Còn <b>'+con+'</b> '+shop.product.conf.product[id].unit+'</span>');
							}
							jQuery('#pNumber'+id).html(shop.product.conf.product[id].buyer_need);

	
							//update tinh trang san pham
							html = '';
							if(shop.product.conf.product[id].buyer <= 0){
								html = '<div class="cBarText2">Khi có đủ <b style="color:#E11545">'+shop.product.conf.product[id].buyer_active+'</b> người mua trở lên, các đơn hàng sẽ có hiệu lực</div>';
							}else{
								if(shop.product.conf.product[id].end < shop.product.conf.product[id].now){
									jQuery('.buying').hide();
									html += '<div class="cBarText2 buying">Muachung đã hết hạn, bạn đã mất cơ hội mua sản phẩm này</div>';
								}else{
									if(shop.product.conf.product[id].buyer >= shop.product.conf.product[id].buyer_active){
										html += '<div class="cBarText2 buying"></div>';//Số lượng có hạn !
									}else{
										html += '<div class="cBarText2">(Cần thêm <b>'+(shop.product.conf.product[id].buyer_active-shop.product.conf.product[id].buyer)+'</b> người nữa để mua được giá này)</div>';
									}
								}
							}
							jQuery('.productStatus', parent).html(html).addClass('updated');
	
							//update bo dem thoi gian
							clearTimeout(shop.product.conf.product[id].counter_id);
							shop.product.countTime(id);
							shop.product.drawBuyer(id);
	
							//update lai nut mua hang
							if(
							   shop.product.conf.product[id].end < shop.product.conf.product[id].now ||
							   shop.product.conf.product[id].buyer >= shop.product.conf.product[id].buyer_need)
							{
								jQuery('.buyNow', parent).addClass('buyNowOut');
							}else if(shop.product.conf.product[id].start > shop.product.conf.product[id].now){
								jQuery('.buyNow', parent).addClass('buyNowWait');
							}else{
								jQuery('.buyNow', parent).removeClass('buyNowOut').removeClass('buyNowWait');
								//update so luong co hoi con lai
								jQuery('#buyerCount'+id).html(shop.product.conf.product[id].buyer_need - shop.product.conf.product[id].buyer);
							}
							//vong lap
							//setTimeout(function(){shop.product.update(id)}, shop.product.conf.product[id].updateTime);
							return;
						}
					}
					//window.location.reload();
				});
			}else{
				//lan dau tien khong load ajax
				shop.product.conf.product[id].first = true;
				//setTimeout(function(){shop.product.update(id)}, shop.product.conf.product[id].updateTime);
			}
		}
	},
	zero:function(number, total){
		number = ''+number;
		total = ''+total;
		var out = number;
		number = number.length;
		total = total.length;
		for(var i=0;i<total-number;i++){
			out = '0'+out;
		}
		return out;
	},
	viewAds:function(obj,id){
		if(jQuery(obj).hasClass('views')){
			jQuery(obj).removeClass();
			jQuery('#viewAds'+id).hide();
		}
		else{
			jQuery(obj).addClass('views');
			jQuery('#viewAds'+id).show();
		}
	},
	loadFB: function(id, fb_html){
		shop.product.conf.fb[shop.product.conf.fb.length] = {id: id, html: fb_html};
	},
	pushFB: function(){
		//chan tinh thanh HCM ko load
		//var city = shop.cookie.get(shop.header.city.conf.city_cookie);
		//if(city == 29) return;
		//load fb tu html
		if(shop.product.conf.fb.length > 0){
			var html,i;
			for(i in shop.product.conf.fb){
				html = '';
				html = decodeURIComponent((shop.product.conf.fb[i].html + '').replace(/\+/g, '%20'));;
//				html = decodeURIComponent(shop.product.conf.fb[i].html);
				jQuery('#FB_'+shop.product.conf.fb[i].id).html(html);
			}
		}
	},
	checkBookInfo: function(type){
		//type = 1 la khach san = 2 la tour
		var tour_name		= shop.util_trim(jQuery("#tour-name").val());
		var tour_phone 		= shop.util_trim(jQuery("#tour-phone").val());
		var tour_cmt 		= shop.util_trim(jQuery("#tour-cmt").val());
		var tour_checkin	= shop.util_trim(jQuery("#tour-checkin").val());
		var tour_checkout	= shop.util_trim(jQuery("#tour-checkout").val());
		var tour_room		= shop.util_trim(jQuery("#tour-room").val());
		var tour_children	= shop.util_trim(jQuery("#tour-children").val());
		var tour_adults		= shop.util_trim(jQuery("#tour-adults").val());
		if(!tour_name || !tour_phone || !tour_cmt || !tour_checkin || !tour_checkout || !tour_room || !tour_children || !tour_adults){
			if(!tour_name){
				shop.raiseError("#tour-name","Chưa nhập họ và tên",1);
				return false;
			}
			else{
				shop.closeErr('#tour-name');
			}
			if(!tour_phone ){
				shop.raiseError("#tour-phone","Chưa nhập số điện thoại",1);
				return false;
			}
			else{
				shop.closeErr('#tour-phone');
			}
			if(!tour_cmt){
				shop.raiseError("#tour-cmt","Chưa nhập số CMTND",1);
				return false;
			}
			else{
				shop.closeErr('#tour-cmt');
			}
			if(!tour_room && type == 1){
				shop.raiseError("#tour-room","Chưa nhập số lượng phòng",1);
				return false;
			}
			else{
				shop.closeErr('#tour-room');
			}
			if(!tour_checkin){
				if(type == 1){
					shop.raiseError("#tour-checkin","Chưa chọn ngày check-in",1);
				}
				else{
					shop.raiseError("#tour-checkin","Chưa chọn ngày khởi hành",1);
				}
				return false;
			}
			else{
				shop.closeErr('#tour-checkin');
			}
			if(!tour_checkout && type == 1){
				shop.raiseError("#tour-checkout","Chưa chọn ngày check-out",1);
				return false;
			}
			else{
				shop.closeErr('#tour-checkout');
			}
			if(!tour_adults && !tour_children){
				shop.raiseError("#tour-adults","Chưa nhập số lượng người",1);
				return false;
			}
			else{
				shop.closeErr('#tour-adults');
			}
			
		}
		return true;
	},
	changePicture : function(images,stt,id,lightBox){
		var src = images.replace("/88/", "/550/");
		$(id).attr('src', src);
		
		for(i=1;i<=5;i++){
			if(i==stt){
				jQuery('#productimg'+i).addClass('activeImgBorder');
				jQuery('#productimg'+i+' > img').removeClass('blurringeffects');
				jQuery('#arrow'+i).addClass('arrowactive');
				if(lightBox == true){
					jQuery('#borderImages'+i).addClass('v6BorderImages v6LightBoxBorder');
				}
				else{
					jQuery('#borderImages'+i).addClass('v6BorderImages');
				}
			}else{
				jQuery('#productimg'+i).removeClass('activeImgBorder');
				jQuery('#productimg'+i+' > img').addClass('blurringeffects');
				jQuery('#arrow'+i).removeClass('arrowactive');
				if(lightBox == true){
					jQuery('#borderImages'+i).removeClass('v6BorderImages v6LightBoxBorder');
				}
				else{
					jQuery('#borderImages'+i).removeClass('v6BorderImages');
				}
			}
		}
	}
};

/**
 * Hien thi danh sach khach hang da mua san pham
 * @param obj The &lt;a&gt; cua link xem them
 */
shop.showMoreBuyer = function(obj){
 var limit = 20; // < 500
  // Xac dinh xem total la bao nhieu
  var p = jQuery(obj).parent().parent();
  var total = p.find('>ul>li>span:first').text().replace(/[^0-9]/g, '');
  var anchor;
  // Da load bao nhieu
  var nbLoaded = p.find('>ul>li').length;
  // Da visible bao nhieu
  var nbVisible = p.find('>ul>li:not(.hidden)').length;
  // Hien thi bang cach bo hidden (loaded truoc do)
  if (nbVisible < nbLoaded) {
    var tail = Math.min(nbVisible + limit, total);
    for (var i = 0; i < tail; i++) {
      $(p.find('>ul>li')[i]).removeClass('hidden');
    }
    anchor = $(p.find('>ul>li')[nbVisible]).attr('id');
    shop.auto_scroll('#'+anchor);
    
    jQuery('.top', p).show();
    if (tail == total) {
      jQuery('.f12', p).hide();
    }
    return;
  }
  
  if (nbLoaded >= total) return;
    
  // Can hien thi them bao nhieu
  var nbNeedToLoad = Math.min(total, nbLoaded + limit) - nbLoaded;
  var offset = nbLoaded;
  
  var itemId = new String(p.find('li:first').attr('id'));
  var arr = itemId.match(/customer([0-9]+)/);
  itemId = arr[1];
  
  var lastIndex = p.find('>ul>li:last>span:first').text().replace(/[^0-9]/g, '');
  anchor = 'customer' + itemId + '_' + (nbLoaded + 1);
  $.ajax({
    async: false,
    type: "POST",
    url: "ajax.php?act=item&code=listBuyer",
    data: {
      id: itemId,
      offset: offset,
      limit: nbNeedToLoad
    },
    timeout: 4000,
    cache: true,
    dataType: "json",
    success: function(obj){
      var c = obj.customer;
      $.each(c, function(key, value) {
        var itemKeyId = itemId + '_' + (++nbLoaded);
        var showIndex = --lastIndex;
        // append zero on left side
        var nbZero = new String(total).length - new String(showIndex).length;
        for (var k = 0; k < nbZero; k++) {
          showIndex = '0' + showIndex;
        }
        p.find('>ul:first').append('<li id="customer' + itemKeyId + '"><span style="color:#999" class="f11">' + showIndex + '. </span><span><a name="customer' + itemKeyId + '">' + value.name + '</a></span></li>');
      });
      shop.auto_scroll('#'+anchor);
      jQuery('.top', p).show();
      // Hidden nut Xem them
      if (lastIndex == 1) {
        jQuery('.f12', p).hide();
      } else {
        jQuery('.f12', p).show();
      }
    },
    error: function(){
    } 
  });
};
 
/**
 * Thu gon danh sach khach hang da mua san pham
 * Chi hien thi 5 nguoi, con lai hidden di
 * @param obj The &lt;a&gt; cua link Thu gon
 */
shop.closeMoreBuyer = function(obj){
  var limit = 20;
  var p = jQuery(obj).parent().parent();
  var nbVisible = p.find('>ul>li:not(.hidden)').length;
  var anchor;
  for (var j = 0; j < limit; j++){
    if (nbVisible-j-1 >= 5) {
      $($('ul > li', p)[nbVisible-j-1]).addClass('hidden');
    } else {
      break;
    }
  }
  
  anchor = $(p.find('>ul>li')[Math.max(0,nbVisible-2*limit)]).attr('id');
  shop.auto_scroll('#'+anchor);
  
  if (nbVisible <= 5 + limit) {
    jQuery('.top', p).hide();
  }
  jQuery('.f12', p).show();	
};

shop.auto_scroll = function(anchor) {
    var target = jQuery(anchor);
    target = target.length && target || jQuery('[name=' + anchor.slice(1) + ']');
    if (target.length) {
        var targetOffset = target.offset().top;
        jQuery('html,body').animate({scrollTop: targetOffset},1000);
        return false;
    }
	return true;
};

shop.activeTabDeal = function(weekly_deal){
	if(weekly_deal){
		jQuery('.buttonDeal').removeClass('buttonDealactive');
		jQuery('.buttonDealWeek').addClass('buttonDealWeekactive');
	}else{
		jQuery('.buttonDeal').addClass('buttonDealactive');
		jQuery('.buttonDealWeek').removeClass('buttonDealWeekactive');
	}
};

/**
 * Popup danh sách ngừoi mua
 * @param 
 */
shop.popupshowMoreBuyer = {
	show : function(itemId,buyer,page_no,type){
		shop.show_overlay_popup('list-ordered-customer', 'Danh sách người mua',
		shop.popupshowMoreBuyer.popupShow(buyer,page_no,itemId,type),
		{
			background: {
				'background-color' : 'transparent'
			},
			border: {
				'background-color' : 'transparent',
				'padding' : '0px'
			},
			title: {
				'display' : 'none'
			},
			content: {
				'padding' : '0px',
				'width' : '350px'
			},
			release:function(){
				
			},
			onclose:function(){
				
			}
		});
	},
	popupShow:function(buyer,page_no,itemId,type){
		var html = shop.popupshowMoreBuyer.theme.displayListCBuyer(buyer, page_no, itemId, 'list-ordered-customer','Danh sách người mua');
		if(type==1){
			return shop.popupSite('list-ordered-customer','Danh sách người mua', html);
		}else{
			jQuery('#idList').remove();
			jQuery('.classic-popup-content').html(html);
			return true;
		}
		
	},
	theme:{
		displayListCBuyer:function(buyer,page_no,itemId){
			var html = '';
			var data = '';
			var t = 0, inc, cs, i;
			jQuery.jCache.maxSize 		= 50;
			var key 					= 'buyer'+itemId+page_no;
			dataCache					= jQuery.jCache.getItem(key);
			if(!dataCache){
				shop.show_loading();
				$.ajax({
					async: false,
					url: 'ajax.php?act=item&code=listBuyerPopupV6',
					type: 'GET',
					data: {id: itemId,page_no:page_no},
					dataType: 'json',
					success: function(obj) {
						if (obj.err == 0) {
							//t = parseInt(obj.total);
							inc = buyer-((page_no-1)*15);
							cs = obj.customer;
							num = 0;
							for (i in cs) {
								num++;
								if(num<16){
									data += '<tr><td  style="font-size:13px;color:#000;padding-left:15px"><span style="display:block;width:210px;height:17px;overflow:hidden">'+(inc--)+'.&nbsp;' + cs[i].name + '</span></td><td style="font-size:11px;color:#707070"><span style="display:block;width:75px;height:17px;overflow:hidden">'+cs[i].created+'</span></td></tr>';
								}
							}
							data += '</table><div style="height: 30px;border-top:1px solid #E0E0E0;padding-top: 10px;position:absolute;bottom:0;width:320px;font-size:13px">';
							if(page_no==1 && num==16){
								data += '<div class="fr"><a style="text-decoration:none;color:#000" onclick="shop.popupshowMoreBuyer.popupShow('+buyer+','+(page_no+1)+','+itemId+',2)"href="javascript:void(0)">Xem tiếp</a></div>';
							}else if(page_no>=2 && num==16){
								data += '<div class="fl"><a style="text-decoration:none;color:#000" onclick="shop.popupshowMoreBuyer.popupShow('+buyer+','+(page_no-1)+','+itemId+',2)" href="javascript:void(0)">Quay lại</a></div><div class="fr"><a style="text-decoration:none;color:#000" onclick="shop.popupshowMoreBuyer.popupShow('+buyer+','+(page_no+1)+','+itemId+',2)" href="javascript:void(0)">Xem tiếp</a></div>';
							}else if(page_no>=2 && num<16){
								data += '<div class="fl"><a style="text-decoration:none;color:#000" onclick="shop.popupshowMoreBuyer.popupShow('+buyer+','+(page_no-1)+','+itemId+',2)" href="javascript:void(0)">Quay lại</a></div>';
							}
						} else {
							html = '<div style="padding:5px">Có lỗi xảy ra! Vui lòng thử lại sau!</div>'
						}
					}
				});
				shop.hide_loading();
				if (buyer > 0){
					dataCache			= jQuery.jCache.setItem(key,data);
				}
			}else{
				data				= dataCache;
			}
			if (buyer > 0 || dataCache) {
				html = shop.join
				('<div id="idList" style="padding:2px 10px;height:480px; position: relative;"><table width="100%" border="0" cellpadding="5" cellspacing="0">')
					('<tr style="height: 35px;"><td colspan="2" style="border-bottom:1px solid #E0E0E0;color:#000"  valign="middle"><b>Đã có '+buyer+' người mua</b></td></tr>')
					(data)
				('<div class="c"></div></div></div>')();
			}
			return html;
		}
	}
};